package com.cmd;

import com.cmd.entity.Stock;
import com.cmd.iface.Order;
import com.cmd.iface.imlp.BuyStock;
import com.cmd.iface.imlp.SellStock;

import java.util.ArrayList;
import java.util.List;

public class Test {

    public static void main(String[] args) {
        Stock stock = new Stock();

        BuyStock buyStock = new BuyStock(stock);
        SellStock sellStock = new SellStock(stock);

        Executor execList = new Executor();
        execList.addOrder(buyStock);
        execList.addOrder(sellStock);

        execList.execAll();

    }

}

class Executor {
    private List<Order> orderList = new ArrayList<>();

    public void addOrder(Order order){
        orderList.add(order);
    }

    public void execAll(){
        for (Order order : orderList) {
            order.execute();
        }
        orderList.clear();
    }
}